package com.scs.application.modules.wm.service;

import com.scs.application.core.service.IBaseService;
import com.scs.application.modules.dept.entity.DeptReturn;
import com.scs.application.modules.sys.model.RestResult;
import com.scs.application.modules.wm.dto.OrthWiDTO;
import com.scs.application.modules.wm.dto.WorkOrderItemDTO;
import com.scs.application.modules.wm.entity.Stock;
import com.scs.application.modules.wm.entity.Transfer;
import com.scs.application.modules.wm.entity.WorkOrder;

import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 入库单 Service
 * </p>
 */

public interface InOrderService extends IBaseService<WorkOrder> {
    /**
     * 根据送货单号转换入库单
     *
     * @param asnKey      送货单
     * @param warehouseId 入库仓库
     * @return
     */
    Map createWorkOrderByDelivery(String asnKey, String warehouseId, String deliveryman, String busUser, double arrivalTemperature, String reagentTeamId,String busType);

    /**
     * 重写删除，删除前清除workOrderItem
     *
     * @param idList
     * @return
     */
    @Override
    boolean removeCascadeByIds(Collection<? extends Serializable> idList);

    /**
     * 根据出库单转换入库单
     *
     * @param outWorkOrder
     * @param transfer
     * @return
     */
    WorkOrder createWorkOrderByOut(WorkOrder outWorkOrder, Transfer transfer);

    /**
     * 根据科室退库转换入库单
     *
     * @param deptReturn
     * @return
     */
    List<WorkOrder> createWorkOrderByDeptReturn(DeptReturn deptReturn);

    /**
     * 打印预览
     *  @param workOrderId
     * @param response
     */
    void preview(String workOrderId, HttpServletResponse response);

    /**
     * 判断是否可以自动转成配送单
     * @param workOrder
     * @return
     */
    boolean allowAutoChangeDist(WorkOrder workOrder);

    /**
     * 判断是否需要调价
     * @param workOrder
     * @return
     */
    boolean allowAutoAdjust(WorkOrder workOrder);
    /**
     * 明细调价
     * @param workOrder
     * @return
     */
    boolean workOderItemAdjust(WorkOrder workOrder);

    /**
     * 判断是否可以自动转成调拨单
     * @param workOrder
     * @return
     */
    boolean allowAutoChangeTransfer(WorkOrder workOrder);


    RestResult isExist(String asnKey);

    /**
     * 二维码扫码入库
     * @param warehouseId
     * @param qrCode
     * @param inOrderId
     * @param deliveryman
     * @param busUser
     * @return
     */
    WorkOrder createWorkOrderByQrCode(String warehouseId, String qrCode, String inOrderId, String deliveryman, String busUser);

    void saveBatchForInOrder(List<WorkOrderItemDTO> entityList);

    /**
     * 骨科耗材验收平台入库
     * @param orthWiDTO
     * @return
     */
    RestResult createWorkOrderByOrthScan(OrthWiDTO orthWiDTO);

    String createByStockImport(List<Stock> stockList);
}
